GBML manual / Motion

move_snap

Rounds this instance’s position to the nearest multiple of grid_x/grid_y on each axis. 0 or a negative value leaves that axis untouched.

Syntax

move_snap(grid_x, grid_y)

Arguments

NameType
grid_xreal
grid_yreal

Returns

Nothing.

Description

Rounds this instance's position to the nearest multiple of grid_x/grid_y on each axis - landing it on a grid cell boundary rather than wherever it happened to stop. Passing 0 or a negative value for either axis leaves that axis untouched, so a single-axis snap is a plain, direct call rather than a special case.

Example

move_snap(16, 16);

Snaps the walker onto the nearest 16-pixel grid intersection on both axes - useful once movement should always end up on a cell boundary, a puzzle game's own tile-locked step rather than free pixel movement.

See also: move_to